using System;
using System.Drawing;
using Diagram.Model;
using Diagram.View;
using PetriDiagram.Model;

namespace PetriDiagram.Tools
{
    [Serializable]
    public class AddTokenTool : TokenTool
    {
        public AddTokenTool( EntityManager entityManager, Diagram.View.Diagram diagram )
            : base( entityManager, diagram )
        {
            Name = "Add token";
        }

        public override void OnLMBDown( Point location )
        {
            Shape shape = Diagram.FindShape( location );

            if( shape == null )
                return;

            if( shape.Entity is Place )
            {
                Place p = shape.Entity as Place;
                p.Tokens++;
            }
            else if( shape.Entity is PetriNetRelation )
            {
                PetriNetRelation r = shape.Entity as PetriNetRelation;
                r.Weight++;
            }

            base.OnLMBDown( location );
        }
    }
}
